package com.yxhl.zoume.domain.interactor.busticket;

import com.google.protobuf.GeneratedMessageV3;
import com.yxhl.protobuf.IsFerryRequest;
import com.yxhl.protobuf.IsFerryResponse;
import com.yxhl.zoume.data.http.repository.busticket.BusTicketRepository;
import com.yxhl.zoume.domain.DomainConstants;
import com.yxhl.zoume.domain.interactor.base.ProtoUseCase;

import javax.inject.Inject;
import javax.inject.Named;

import rx.Observable;
import rx.Scheduler;

/**
 * Created by Xboy on 16/6/12.
 */

public class CheckIsNeedShuttleUseCase extends ProtoUseCase<IsFerryResponse> {
    private final BusTicketRepository repository;

    @Inject
    public CheckIsNeedShuttleUseCase(@Named(DomainConstants.UI_THREAD) Scheduler uiThread,
                                     @Named(DomainConstants.EXECUTOR_THREAD) Scheduler executorThread,
                                     BusTicketRepository repository) {
        super(uiThread, executorThread);
        this.repository = repository;
    }

    @Override
    protected Observable<IsFerryResponse> buildObservable(GeneratedMessageV3 message) {
        return repository.checkIsNeedShuttle((IsFerryRequest) message)
                .observeOn(uiThread)
                .subscribeOn(executorThread);
    }
}
